//
//  OrderController.swift
//  ExpressManager
//
//  Created by yongkang on 2017/11/3.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit
import SnapKit

class OrderController: UIViewController {
    
    @IBOutlet weak var typeSegment: UISegmentedControl!
    
    @IBOutlet weak var orderListView: UIView!
    
    @IBOutlet weak var mapView: UIView!
    
    let statusHeight = UIApplication.shared.statusBarFrame.height
    var scrrenHeight = UIScreen.main.bounds.height
    var scrrenWidth = UIScreen.main.bounds.width
    

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let navigHeight = self.navigationController!.navigationBar.frame.height
        
        self.typeSegment.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(self.view.snp.top).offset(statusHeight + navigHeight + 10)
            make.centerX.equalTo(self.view)
            make.height.equalTo(30)
            make.left.equalTo(80)
            make.right.equalTo(-80)
        }
        
        self.orderListView.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(self.typeSegment.snp.bottom).offset(10)
            make.centerX.equalTo(self.view)
            make.height.equalTo(scrrenHeight - statusHeight - navigHeight - 50)
            make.width.equalTo(scrrenWidth)
        }
        
        self.mapView.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(self.typeSegment.snp.bottom).offset(20)
            make.centerX.equalTo(self.view)
            make.height.equalTo(scrrenHeight - statusHeight - navigHeight - 50)
            make.width.equalTo(scrrenWidth)
        }
        
        orderListView.isHidden = false
        mapView.isHidden = true

    }
    
    
    

    @IBAction func indexChange(_ sender: UISegmentedControl) {
        
        switch typeSegment.selectedSegmentIndex {
        case 0:
            orderListView.isHidden = false
            mapView.isHidden = true
        case 1:
            orderListView.isHidden = true
            mapView.isHidden = false
        default:
            break;
        }
    }
    
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
